#include "sema_thread.h"

void main()
{   
    int err;
    pthread_t tid1,tid2;
    void * tret;
    
    sem_init(&mutex,0,1);
    sem_init(&full,0,0);
    sem_init(&empty,0,N);
  
    if((fd = open("sairam",O_RDWR,PERMS)) < 0)
    {
     perror("Failed to open:");
     exit(0);
    }

    in = 0;

    err = pthread_create(&tid1, NULL,producer,NULL);
    if (err != 0)
          printf("can't create producer: %s\n", strerror(err));
    
    err = pthread_create(&tid2, NULL,consumer,NULL);
    if (err != 0)
          printf("can't create consumer: %s\n", strerror(err));

    err = pthread_join(tid1, &tret);
          if (err != 0)
                printf("can't join with producer: %s\n", strerror(err));

    err = pthread_join(tid2, &tret);
          if (err != 0)
                printf("can't join with consumer: %s\n", strerror(err));
}
